package com.baihan.angus.app.game.busshow.pop_dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.baihan.angus.app.game.basic.utils.AppUtil;
import com.baihan.angus.app.game.basic.utils.ComUtil;
import com.baihan.angus.app.game.busshow.R;

public class MsgTipDialog extends Dialog {

    private Context mContext;
    private WindowManager.LayoutParams mLayoutParams;
    private TextView tvMsg;
    private ImageView ivMsg;
    private String message;
    private Drawable daMsgPic;

    public MsgTipDialog(@NonNull Context context) {
        super(context, R.style.FullDialog);
        this.mContext = context;
        initContentView();
        init(context);
    }

    private void init(Context context) {
        this.mContext = context;
        Window dialogWindow = this.getWindow();
        mLayoutParams = dialogWindow.getAttributes();
        mLayoutParams.width = AppUtil.getScreenWidth(context);
        mLayoutParams.height = ComUtil.Dp2Px(context, 175);
        dialogWindow.setAttributes(mLayoutParams);
        dialogWindow.getDecorView().setPadding(120, 0, 120, 0);
        dialogWindow.getDecorView().setBackgroundResource(android.R.color.transparent);
        dialogWindow.setGravity(Gravity.CENTER);
    }

    private void initContentView() {
        View dialogView = LayoutInflater.from(this.getContext()).inflate(R.layout.dialog_msg_tip, (ViewGroup) null);
        setContentView(dialogView);
        tvMsg = dialogView.findViewById(R.id.tvMsg);
        ivMsg = dialogView.findViewById(R.id.ivMsg);

        setMessage(message);
        setMsgPic(daMsgPic);
    }

    public void setMessage(String message) {
        this.message = message;
        tvMsg.setText(message);
    }

    public void setMsgPic(Drawable daMsgPic) {
        this.daMsgPic = daMsgPic;
        ivMsg.setImageDrawable(daMsgPic);
    }
}
